package com.vitabuybuy.tv.ui.mine.order

import android.os.Bundle
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.vitabuybuy.tv.R
import com.vitabuybuy.tv.databinding.ActivityLogisticsInforBinding
import com.vitabuybuy.tv.dto.LogisticsDto
import com.library.common.base.BaseActivity
import com.vitabuybuy.tv.ui.mine.order.adapter.LogisticsInforAdapter
import com.vitabuybuy.tv.ui.mine.order.viewmodel.OrderViewModel
import kotlinx.android.synthetic.main.activity_logistics_infor.*

/**
 * 作者：SimGa
 * 日期：2019/12/9
 * 时间：15:53
 * 包名：com.seefun.app.activities.goods
 */
class LogisticsInforActivity : BaseActivity<OrderViewModel, ActivityLogisticsInforBinding>() {
    override val isUseBaseTitleBar: Boolean
        get() = true
    override val layoutId: Int
        get() = R.layout.activity_logistics_infor

    private var orderId: Int? = null

    private val mAdapter by lazy(LazyThreadSafetyMode.NONE) { LogisticsInforAdapter() }

    override fun onGetBundle(bundle: Bundle?) {
        orderId = bundle?.getInt("orderId")
    }

    override fun initView(savedInstanceState: Bundle?) {
        setTitle("物流详情")
        mBinding.viewModel = viewModel
        listView.apply {
            adapter = mAdapter
            layoutManager = LinearLayoutManager(mContext, RecyclerView.VERTICAL, false)
        }

        val list = ArrayList<LogisticsDto.ExpressBean>()
        for (i in 1 until 10) {
            val bean = LogisticsDto.ExpressBean()
            bean.acceptStation = "您的订单在【广州外单分拣中心】分拣完成送往【广州中心营业部】"
            bean.acceptTime = "11/28 \n 18:48:47"
            list.add(bean)
        }
        mAdapter.setNewData(list)
    }

    companion object {
        fun openActivity(mContext: BaseActivity<*, *>, orderId: Int?) {
            orderId?.run {
                val bundle = Bundle()
                bundle.putInt("orderId", this)
                mContext.startActivity(bundle, LogisticsInforActivity::class.java)
            }
        }
    }
}
